package com.cib.xagcjs.web;


import com.cib.xagcjs.biz.EcnyPaymentNotifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;
import java.util.Objects;

/**
 * 接收区块链推送消息 （资金拨付）
 * 数币开放接口
 */
@Controller
@RequestMapping(value = "/epay")
public class EcnyPaymentNotifyController {

    @Autowired
    private EcnyPaymentNotifyService ecnyPaymentNotifyService;

    /**
     * 区块链发起
     * @param req 请求
     * @return 执行结果
     */
    @PostMapping("/notify")
    @ResponseBody
    public String receiveMessage (@RequestBody String req) {
        return ecnyPaymentNotifyService.sendMessage(req);
    }

    /**
     * 行方发起 （支付结果通知接口）
     * @param req 请求
     * @return 执行结果
     */
    @PostMapping("/sendNotify")
    @ResponseBody
    public String sendNotify (@RequestBody Map<String, Objects> req) throws Exception {
        return ecnyPaymentNotifyService.sendNotify(req);
    }
}
